package com.yyfax.pay.order.model.to;

import org.apache.commons.lang3.StringUtils;

import com.yyfax.framework.exception.YYException;
import com.yyfax.framework.yyfax.enums.RspCodeEnum;
import com.yyfax.pay.common.model.to.YYPayParams;

/**
 * 鉴权三要素填写页面/支付模式选择页面 --> 请求参数
 * 
 * @author buyi
 * @date 2017-04-13 16:06:33
 * @since v1.0.0
 */
@SuppressWarnings("serial")
public class WebFormConfirmParams extends YYPayParams {

	/** 支付模块订单业务主键 */
	private String payOrderId;
	/** 商户编号 */
	private String merchantCode;
	/** 用户ID */
	// private String userId;
	/** 支付模式 */
	private String payMode;
	/** 身份证号 */
	private String idNo;
	/** 姓名 */
	private String name;
	/** 银行卡号 */
	private String cardNo;

	/** 表单提交的 身份证号 */
	private String formIdNo;
	/** 表单提交的姓名 */
	private String formName;
	/** 表单提交的银行卡号 */
	private String formCardNo;

	public String getPayOrderId() {
		return payOrderId;
	}

	public void setPayOrderId(String payOrderId) {
		this.payOrderId = payOrderId;
	}

	public String getMerchantCode() {
		return merchantCode;
	}

	public void setMerchantCode(String merchantCode) {
		this.merchantCode = merchantCode;
	}

	public String getPayMode() {
		return payMode;
	}

	public void setPayMode(String payMode) {
		this.payMode = payMode;
	}

	public String getIdNo() {
		return idNo;
	}

	public void setIdNo(String idNo) {
		this.idNo = idNo;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCardNo() {
		return cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	public String getFormIdNo() {
		return formIdNo;
	}

	public void setFormIdNo(String formIdNo) {
		this.formIdNo = formIdNo;
	}

	public String getFormName() {
		return formName;
	}

	public void setFormName(String formName) {
		this.formName = formName;
	}

	public String getFormCardNo() {
		return formCardNo;
	}

	public void setFormCardNo(String formCardNo) {
		this.formCardNo = formCardNo;
	}

	@Override
	public boolean validate() throws YYException {
		if (StringUtils.isNotBlank(this.formIdNo)) {
			this.formIdNo = this.formIdNo.trim();
		}

		if (StringUtils.isNotBlank(this.formName)) {
			this.formName = this.formName.trim();
		}

		if (StringUtils.isNotBlank(this.formCardNo)) {
			this.formCardNo = this.formCardNo.trim();
		}

		if (StringUtils.isBlank(this.payOrderId)) {
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "payOrderId不能为空", "payOrderId不能为空");
		}

		if (StringUtils.isBlank(this.merchantCode)) {
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "merchantCode'不能为空", "merchantCode'不能为空");
		}

		return true;
	}

	@Override
	public String[] signFields() {
		return new String[] { "payOrderId", "merchantCode", "idNo", "name", "cardNo" };
	}

}
